package com.sina.weibo.view;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import com.sina.weibo.RPCHelper;
import com.sina.weibo.Utils;
import com.sina.weibo.models.UserInfo;
import java.io.File;
import java.util.Hashtable;
import java.util.Map;

public class UserInfoListItemView extends LinearLayout
{
  private static Map<String, ListView> downloading = new Hashtable();
  private Context context;
  private TextView mNick;
  private TextView mNum;
  private ImageView mPortrait;
  private int mReadMode;
  private ListView parent;
  public UserInfo ui;

  public UserInfoListItemView(Context paramContext, ListView paramListView, UserInfo paramUserInfo, boolean paramBoolean, int paramInt)
  {
    super(paramContext);
    this.parent = paramListView;
    this.context = paramContext;
    View localView = ((LayoutInflater)paramContext.getSystemService("layout_inflater")).inflate(2130903087, this);
    TextView localTextView1 = (TextView)findViewById(2131624050);
    this.mNick = localTextView1;
    ImageView localImageView = (ImageView)findViewById(2131624049);
    this.mPortrait = localImageView;
    TextView localTextView2 = (TextView)findViewById(2131623997);
    this.mNum = localTextView2;
    this.mReadMode = paramInt;
    update(paramUserInfo, paramBoolean, paramInt);
  }

  public void update(Object paramObject, boolean paramBoolean, int paramInt)
  {
    UserInfo localUserInfo = (UserInfo)paramObject;
    this.ui = localUserInfo;
    TextView localTextView1 = this.mNick;
    String str1 = this.ui.nick;
    localTextView1.setText(str1);
    TextView localTextView2 = this.mNum;
    String str2 = String.valueOf(this.context.getString(2131427455));
    StringBuilder localStringBuilder1 = new StringBuilder(str2);
    int i = this.ui.attmenum;
    StringBuilder localStringBuilder2 = localStringBuilder1.append(i);
    String str3 = this.context.getString(2131427458);
    String str4 = str3;
    localTextView2.setText(str4);
    this.mPortrait.setVisibility(0);
    String str8;
    if (this.ui.portrait != null)
    {
      ImageView localImageView1 = this.mPortrait;
      Bitmap localBitmap1 = Utils.outputRoundRectBitmap(BitmapFactory.decodeResource(this.context.getResources(), 2130838011));
      localImageView1.setImageBitmap(localBitmap1);
      Map localMap1 = downloading;
      String str5 = this.ui.portrait;
      if (!localMap1.containsKey(str5))
      {
        String str6 = this.context.getCacheDir().getAbsolutePath();
        String str7 = this.ui.portrait;
        str8 = Utils.checkCache(str6, str7);
        if (str8 != null)
          break label297;
        Map localMap2 = downloading;
        String str9 = this.ui.portrait;
        ListView localListView = this.parent;
        Object localObject = localMap2.put(str9, localListView);
        LoadPictureTask localLoadPictureTask = new LoadPictureTask(null);
        String[] arrayOfString = new String[1];
        String str10 = this.ui.portrait;
        arrayOfString[0] = str10;
        AsyncTask localAsyncTask = localLoadPictureTask.execute(arrayOfString);
      }
    }
    while (true)
    {
      return;
      label297: Bitmap localBitmap2 = BitmapFactory.decodeFile(str8);
      if (localBitmap2 != null)
      {
        ImageView localImageView2 = this.mPortrait;
        Bitmap localBitmap3 = Utils.outputRoundRectBitmap(localBitmap2);
        localImageView2.setImageBitmap(localBitmap3);
        continue;
      }
      boolean bool = new File(str8).delete();
      ImageView localImageView3 = this.mPortrait;
      Bitmap localBitmap4 = Utils.outputRoundRectBitmap(BitmapFactory.decodeResource(this.context.getResources(), 2130838011));
      localImageView3.setImageBitmap(localBitmap4);
    }
  }

  class LoadPictureTask extends AsyncTask<String, Void, String[]>
  {
    private LoadPictureTask()
    {
    }

    protected String[] doInBackground(String[] paramArrayOfString)
    {
      String[] arrayOfString = new String[2];
      String str1 = paramArrayOfString[0];
      Object localObject = null;
      arrayOfString[0] = str1;
      try
      {
        RPCHelper localRPCHelper = RPCHelper.getInstance(UserInfoListItemView.this.getContext());
        String str2 = UserInfoListItemView.this.context.getCacheDir().getAbsolutePath();
        String str3 = localRPCHelper.getPicture(str1, str2);
        File localFile = new File(str3);
        if (localFile.exists())
        {
          String str4 = localFile.toString();
          localObject = str4;
        }
        arrayOfString[1] = localObject;
        label88: return arrayOfString;
      }
      catch (Exception localException)
      {
        break label88;
      }
    }

    protected void onPostExecute(String[] paramArrayOfString)
    {
      String str1 = paramArrayOfString[0];
      String str2 = paramArrayOfString[1];
      ListView localListView;
      Bitmap localBitmap1;
      int k;
      if (str2 != null)
      {
        localListView = (ListView)UserInfoListItemView.downloading.get(str1);
        localBitmap1 = BitmapFactory.decodeFile(str2);
        int i = localListView.getFirstVisiblePosition();
        int j = localListView.getChildCount();
        k = 0;
        if (k >= j)
          Object localObject = UserInfoListItemView.downloading.remove(str1);
      }
      else
      {
        return;
      }
      if (!(localListView.getChildAt(k) instanceof UserInfoListItemView));
      while (true)
      {
        k += 1;
        break;
        UserInfoListItemView localUserInfoListItemView = (UserInfoListItemView)localListView.getChildAt(k);
        if (!localUserInfoListItemView.ui.portrait.equals(str1))
          continue;
        if (localBitmap1 != null)
        {
          if (localBitmap1.isRecycled())
            localBitmap1 = BitmapFactory.decodeFile(str2);
          ImageView localImageView1 = localUserInfoListItemView.mPortrait;
          Bitmap localBitmap2 = Utils.outputRoundRectBitmap(localBitmap1);
          localImageView1.setImageBitmap(localBitmap2);
          continue;
        }
        ImageView localImageView2 = localUserInfoListItemView.mPortrait;
        Bitmap localBitmap3 = Utils.outputRoundRectBitmap(BitmapFactory.decodeResource(UserInfoListItemView.this.context.getResources(), 2130838011));
        localImageView2.setImageBitmap(localBitmap3);
      }
    }

    protected void onPreExecute()
    {
    }

    protected void onProgressUpdate(Void[] paramArrayOfVoid)
    {
    }
  }
}

/* Location:           D:\Program Files\eclipse\apktool-r01-3\新浪微博\classes.dex.dex2jar.jar
 * Qualified Name:     com.sina.weibo.view.UserInfoListItemView
 * JD-Core Version:    0.6.0
 */